﻿// Copyright (c) Vitaly Kamiansky. All rights reserved. 
// See License.txt in the project root.

using System;
using System.Collections.Generic;

namespace Property.Objects
{
    public partial class ValidationInputPropertyPrototype<T> : DecoupledPropertyPrototype<T>, IValidationInputPropertyPrototype<T>
    {
        public ValidationInputPropertyPrototype(IReloaderPrototype<T> reloaderPrototype, Func<T, IEnumerable<string>> validate)
            : base(reloaderPrototype)
        {
            _Validate = validate;
        }

        //=//

        protected readonly Func<T, IEnumerable<string>> _Validate;

        public IValidationInputProperty<T> Create(T defaultValue)
        {
            return new PropertyInstance(_ReloaderPrototype, _Validate, defaultValue);
        }
    }
}
